package com.yuerlive.rainbow.module.live.presenter;

import com.yuerlive.rainbow.api.LiveFinishApi;
import com.yuerlive.rainbow.api.LiveFinishService;
import com.yuerlive.rainbow.base.BasePresenterImpl;
import com.yuerlive.rainbow.entity.BaseData;
import com.yuerlive.rainbow.entity.RecommendLive;
import com.yuerlive.rainbow.rx.RxHelper;
import com.yuerlive.rainbow.rx.RxObserver;

import java.util.List;

/**
 * Created by Admin on 2017/6/24.
 */

public class LiveFinishPresenter extends BasePresenterImpl implements LiveFinishContract.Presenter {
    private LiveFinishContract.View view;
    private LiveFinishService service;
    public LiveFinishPresenter(LiveFinishContract.View view) {
        this.view = view;
        this.view.setPresenter(this);
        service = LiveFinishApi.getInstance().liveService;
    }
    @Override
    public void getRecommendLive() {
        view.showLoading();
        service.reconmmendLive()
                .compose(RxHelper.toUI())
                .subscribe(new RxObserver<BaseData<List<RecommendLive>>>(this) {
                    @Override
                    protected void onSuccess(BaseData<List<RecommendLive>> liveDetailDataBaseData) {
                        view.hideLoading();
                        view.showRecommendLive(liveDetailDataBaseData.getObject());
                    }

                    @Override
                    protected void onFail(String message) {
                    }
                });
    }
}
